package com.ljx.mq.springboot.work;

import com.rabbitmq.client.Channel;
import org.springframework.amqp.rabbit.annotation.Queue;
import org.springframework.amqp.rabbit.annotation.RabbitListener;
import org.springframework.amqp.support.AmqpHeaders;
import org.springframework.messaging.handler.annotation.Header;
import org.springframework.stereotype.Component;

import java.io.IOException;


@Component
public class Consumer22 {

    @RabbitListener(queuesToDeclare = @Queue("helloBoot1"))
    public void consumer(String msg, @Header(AmqpHeaders.DELIVERY_TAG) long deliverTag, Channel channel) throws IOException {
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        System.out.println("2收到的内容：" + msg);
        channel.basicAck(deliverTag, true);
    }
}
